package com.mz.mattress.client.config;

import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

public class ExecutorCondition implements Condition {

    // 动态创建bean
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {

        BeanDefinitionRegistry registry = context.getRegistry();

        boolean executor1 = registry.containsBeanDefinition("executor1");

        return !executor1;
    }

}
